﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;

namespace ConsoleApp1
{
    public static class WxXmlParser
    {
        public static T? ParseWithCData<T>(string xml) where T : class
        {
            var doc = new XmlDocument();
            doc.LoadXml(xml);

            using (var reader = new XmlNodeReader(doc))
            {
                var serializer = new XmlSerializer(typeof(T));
                var t = serializer.Deserialize(reader);
                if (t != null)
                {
                    return (T)t;
                }
            }
            return default;
        }
    }
}
